import time
import datetime

# a = [2, 12, 2, 3, 4, 9, 8, 7, 6, 5, 11]
def bubble_sort(a):
    not_sorted = True

    start = time.time()

    while not_sorted:
        not_sorted = False
        for i in range(len(a) - 1):
            if a[i] > a[i + 1]:
                not_sorted = True
                a[i], a[i + 1] = a[i + 1], a[i]
    finish = time.time()
    return (finish - start) * 1000

names = ['m1_sorted.txt', 'm2_reverse.txt', 'm3_shuffle.txt']
for i in names:
    a = []
    with open(i) as f:
        for j in f:
            a.append(str(j))
    f.close()
    mytime = bubble_sort(a)
    print(f"File {i} time {mytime:.1f} ms")
# input()
